$(document).ready(function(){
$('#playlistwindow table').click(function(){
	$('tbody tr:odd').css('background-color','#dddddd');
	$('tbody tr:even').css('background-color','#FEFEFE');

});

playlistadd('90','TV','Cartoons','Aqua Teen Hunger Force','Aqua Teen Hunger Force/Season 02/aqua.teen.hunger.force.203.circus.dvdrip.abn.avi');
playlistadd('85','TV','Cartoons','Beast Wars','Beast Wars/Beast Machines - 105 - Forbidden Fruit.mpg');
playlistadd('86','TV','Cartoons','Beast Wars','Beast Wars/Beast Wars - 204 - Tangled Web.avi');
playlistadd('87','TV','Cartoons','Beast Wars','Beast Wars/Beast Machines - 204 - In Darkest Knight.mpg');
playlistadd('88','TV','Cartoons','Beast Wars','Beast Wars/Beast Wars - 308 - Go With the Flow.avi');
playlistadd('95','TV','Cartoons','Aqua Teen Hunger Force','Aqua Teen Hunger Force/Season 02/aqua.teen.hunger.force.202.bad.replecant.dvdrip.abn.avi');
playlistadd('96','TV','Cartoons','Aqua Teen Hunger Force','Aqua Teen Hunger Force/Season 02/aqua.teen.hunger.force.205.dumber.days.dvdrip.abn.avi');
playlistadd('97','TV','Cartoons','Aqua Teen Hunger Force','Aqua Teen Hunger Force/Season 02/aqua.teen.hunger.force.206.interfection.dvdrip.abn.avi');
playlistadd('98','TV','Cartoons','Aqua Teen Hunger Force','Aqua Teen Hunger Force/Season 01/aqua.teen.hunger.force.107.revenge.of.the.mooninites.dvdrip.abn.avi');
playlistadd('99','TV','Cartoons','Aqua Teen Hunger Force','Aqua Teen Hunger Force/Season 01/aqua.teen.hunger.force.108.mc.pee.pants.dvdrip.abn.avi');
playlistadd('100','TV','Cartoons','Aqua Teen Hunger Force','Aqua Teen Hunger Force/Season 01/aqua.teen.hunger.force.106.ol.drippy.dvdrip.abn.avi');



});


function playlistadd(id, type, category, title, filename) {
	var output = "<tr><td class=\"add\" id=\"" + id + "\">" + "play</td><td>" + title + "</td><td>" + filename + "</td>";
	var control = "<td><a href=\"#\" class=\"up\">Up</a> <a href=\"#\" class=\"down\">Down</a></td></tr>" 
	$('#playlistwindow tbody').append(output + control);
	sortbuttons();
	console.log(output + control);
        $('tbody tr:odd').css('background-color','#dddddd');
        $('tbody tr:even').css('background-color','#FEFEFE');
}

function shuffleplaylist() {
	$('#playlistwindow tbody').shuffle();
	sortbuttons();

}


function sortbuttons() {
    $(".up,.down").unbind('click');
    $(".up,.down").click(function(){
        var row = $(this).parents("tr:first");
        if ($(this).is(".up")) {
            row.insertBefore(row.prev());
        } else {
            row.insertAfter(row.next());
        }
    });
    $('td.add').unbind('click');
    $('td.add').click(function() {
		alert(this.id);
		var row = $(this).parents("tr:first");
		row.remove();
		sortbuttons();
    });

}


function getnextvideo() {
	var nextvid = $('#playlistwindow tbody tr:first td:first');
	alert(nextvid.attr('id'));
	console.log(nextvid);
	$('#playlistwindow tbody tr:first').remove();

}
